/**
 * ShoppingCart 业务逻辑实现类
 * @author WangXinLei
 * @date 2014-09-10
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.ShoppingCart;
import com.chnbst.bstyun.model.vo.ShoppingCartVo;
import com.chnbst.bstyun.service.ShoppingCartService;

@Transactional
@Service
public class ShoppingCartServiceImpl  extends BaseService implements ShoppingCartService {
	
	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(ShoppingCartServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.ShoppingCartMapper";
		
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertShoppingCart(ShoppingCart shoppingCart) {
		return DaoHelper.insert(nameSpace, "insertShoppingCart", shoppingCart);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateShoppingCart(ShoppingCart shoppingCart) {
		return DaoHelper.update(nameSpace, "updateShoppingCart", shoppingCart);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<ShoppingCartVo> selectShoppingCartVosByUserId(Integer userId) {
		return (List<ShoppingCartVo>)DaoHelper.list(nameSpace, "selectShoppingCartVosByUserId", userId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Map<String, Object> selectShoppingCartCountByUserId(Integer userId) {
		return (Map<String, Object>) DaoHelper.query(nameSpace, "selectShoppingCartCountByUserId", userId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public ShoppingCart selectShoppingCartByShoppingCartId(
			Integer shoppingCartId) {
		return (ShoppingCart)DaoHelper.query(nameSpace, "selectShoppingCartByShoppingCartId", shoppingCartId);
	}

}
